home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / pcmagazi / 1989 / 18 / curpath.bas < prev    next >
BASIC Source File  |  1989-09-20  |  1KB  |  37 lines

  1. '****** CURPATH.BAS
  2.  
  3. 'Copyright (c) 1988, Ziff Comunications Co.
  4. 'PC Magazine * Don Malin
  5. 'Queries the current directory in OS/2
  6.  
  7. DEFINT A-Z                              'Default to integers
  8.  
  9. DECLARE FUNCTION DosQCurDir%(BYVAL Drive, BYVAL StrSeg, BYVAL StrOff, _
  10.     SEG Length)
  11.  
  12. DECLARE FUNCTION CurPath$(Drive$)    'BASIC wrapper for OS/2 call
  13.  
  14. INPUT "Which drive (ENTER for current drive)"; Drive$   'ask for drive to check
  15. PRINT "The current directory is "; CurPath$(Drive$)   'print the directory
  16.  
  17. FUNCTION CurPath$(Drive$) STATIC
  18.  
  19.     IF LEN(Drive$) THEN         'Was a drive letter given?
  20.     DriveNumber = ASC(UCASE$(Drive$)) - 64   'Yes, convert to drive number
  21.     ELSE
  22.     DriveNumber = 0             'No, use the current drive
  23.     END IF
  24.  
  25.     BufLen = 128               'OS/2 needs buffer's length
  26.     Path$ = Space$(BufLen)     'Buffer to receive the name
  27.                                         'invoke the function
  28. DOSError = DosQCurDir%(DriveNumber, VARSEG(Path$), SADD(Path$), BufLen)
  29.  
  30.     IF DOSError THEN              'Show there was an error
  31.     CurPath$ = "Error" + STR$(DOSError)  'Append the OS/2 error number
  32.     ELSE                     'Return what precedes CHR$(0)
  33.     CurPath$ = "\" + LEFT$(Path$, INSTR(Path$, CHR$(0)) - 1)
  34.     END IF
  35.  
  36. END FUNCTION
  37.